/*
 * @lc app=leetcode.cn id=27 lang=javascript
 *
 * [27] 移除元素
 */

// @lc code=start
/**
 * @param {number[]} nums
 * @param {number} val
 * @return {number}
 */
var removeElement = function(nums, val) {
    let arrLength = 0
    for (let index = 0; index < nums.length; index++) {
        let e = nums[index];

        if (e === val) {
            nums.splice(index, 1)
            index--
        } else {
            ++arrLength
        }
        
    }
    return arrLength ? arrLength + 1 : arrLength
};
// @lc code=end

